def fetch_data_pro_bar(ts_code, start_date, end_date, basic, freq):
    import pymysql
    pymysql.install_as_MySQLdb()

    import tushare as ts
    from sqlalchemy import create_engine

    ts.pro_api('09640b7c249de22f51c81fa10ebadcc2c31924864746e333e5ffbe2c')
    # 全部指数
    asset = ''
    if basic == 'index':
        asset = 'I'
    elif basic == 'stock':
        asset = 'E'
    elif basic == 'fund':
        asset = 'FD'
    elif basic == 'cb':
        asset = 'E'
    df = ts.pro_bar(ts_code=ts_code, start_date=start_date, end_date=end_date, asset=asset, freq=freq)
    print(df.shape[0])
    engine = create_engine('mysql://root:root@127.0.0.1/gupiao?charset=utf8mb4')
    df.to_sql('pro_bar_'+basic, engine, index=False, if_exists='append', chunksize=5000)
    print("数据获取成功 代码: " + ts_code + " 时间: " + start_date + "--->" + end_date)
    

